﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RadarMonitor.FTPMonitor
{
    class ProductsMonitor
    {
        public readonly FTPMonitor monitor;

        #region 单例
        private static readonly Lazy<ProductsMonitor>
            lazy =
            new Lazy<ProductsMonitor>
                (() => new ProductsMonitor());

        public static ProductsMonitor Instance { get { return lazy.Value; } }

        private ProductsMonitor()
        {
            var config = RadarMonitor.Setting.Setting.GetConfig().productFTP;
            monitor = new FTPMonitor(config.url, config.UID,config.PWD);
            monitor.AlarmInterval = config.AlarmRange;
            monitor.QueryInterval = config.CheckInterval;
        }
        #endregion

        public void Start()
        {
            var config = RadarMonitor.Setting.Setting.GetConfig().productFTP;
            monitor.FTPUri = config.url;
            monitor.AlarmInterval = config.AlarmRange;
            monitor.QueryInterval = config.CheckInterval;
            monitor.Start();
        }

        public void Stop()
        {
            monitor.Stop();
        }
    }
}
